<template>
	<view class="container">
		<view class="tui-cmt-primary">
			<view class="tui-cmt-cell tui-cell-last">
				<view class="tui-header-box">
					<view class="tui-userinfo-box">
						<image :src="commentInfo.parent.memberAvatar" class="tui-avatar"></image>
						<view class="tui-nickname-box">
							<view class="tui-cmt-nickname">{{commentInfo.parent.memberNickname}}</view>
							<view class="tui-cmt-time" v-text="relativeTimeGetter.getText(commentInfo.parent.createTime)"></view>
						</view>
					</view>
					<view class="tui-fabulous" :class="{ 'tui-primary': isFabulous }" @tap="btnFabulous">
						<text>{{ fabulous == 0 ? '赞' : fabulous }}</text>
						<tui-icon :name="isFabulous ? 'agree-fill' : 'agree'" :size="15" :color="isFabulous ? '#5677fc' : '#9a9a9a'"></tui-icon>
					</view>
				</view>
				<view class="tui-cmt-content">{{commentInfo.parent.content}}</view>
			</view>
		</view>
		<view class="tui-empty"></view>
		<view class="tui-cmt-title">全部回复（{{commentInfo.children.length}}）</view>
		<view class="tui-cmtbox">
			<view class="tui-cmt-cell" v-for="(item, index) in commentInfo.children" :key="index">
				<view class="tui-header-box">
					<view class="tui-userinfo-box">
						<image :src="item.memberAvatar" class="tui-avatar"></image>
						<view class="tui-nickname-box">
							<view class="tui-cmt-nickname">{{ item.memberNickname }} <text style="color: #666666; font-size: 15rpx;" v-text=" item.backMemberId ? ' 回复 ' + (item.backMemberNickname) : ''"></text></view>
							
							<view class="tui-cmt-time" v-text="relativeTimeGetter.getText(item.createTime)"></view>
						</view>
					</view>
					<view class="tui-fabulous" :class="[item.isFabulous ? 'tui-primary' : '']" :id="index" @tap="cmtFabulous">
						<text>{{ item.fabulous == 0 ? '赞' : item.fabulous }}</text>
						<tui-icon :name="item.isFabulous ? 'agree-fill' : 'agree'" :size="15" :color="item.isFabulous ? '#5677fc' : '#9a9a9a'"></tui-icon>
					</view>
				</view>
<!-- 				<view class="tui-reply-box" v-if="item.backMemberId">
					<tui-list-cell backgroundColor="#f2f2f2" :size="28" v-for="(items, index2) in commentInfo.children" :key="index2" :unlined="true">
						<view class="tui-flex-1 tui-reply-nickname">{{ items.memberNickname }}</view>
						<view class="tui-flex-1">{{ items.content }}</view>
					</tui-list-cell>
				</view> -->
				<view class="tui-cmt-content">{{ item.content }}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import mpHtml from 'mp-html/dist/uni-app/components/mp-html/mp-html'
	import communityApi from '@/request/api/communityApi.js'
	import relativeTimeGetter from "@/utils/RelativeTimeGetter.js"
	import userUtils from "@/utils/userUtils.js"
	
	export default {
	
		data() {
			return {
				relativeTimeGetter:relativeTimeGetter,
				commentId:'',
				commentInfo:'',
			}
		},
		methods: {
			onLoad(params) {
				this.commentId = params.commentId;
				
				this.init()
			},
			init(){
				communityApi.getCommentInfoById(this.commentId).then(response =>{
					this.commentInfo = response.data
					console.log(response)
				})
			}
		}
	}
</script>

<style>
page {
	background-color: #fff;
	color: #333;
}

.container {
	padding-bottom: 110rpx;
	box-sizing: border-box;
}

.tui-empty {
	width: 100%;
	height: 10rpx;
	background-color: #eaeef1;
}

.tui-cmt-title {
	font-size: 30rpx;
	font-weight: bold;
	position: relative;
	padding: 20rpx 30rpx;
	box-sizing: border-box;
	margin-bottom: 20rpx;
}

.tui-cmt-title::after {
	content: '';
	position: absolute;
	left: 12rpx;
	top: 30%;
	width: 6rpx;
	height: 40%;
	background: #5677fc;
}

.tui-cmt-cell {
	width: 100%;
	padding: 26rpx 30rpx;
	box-sizing: border-box;
	position: relative;
}

.tui-cmt-cell::after {
	content: '';
	position: absolute;
	border-bottom: 1rpx solid #eaeef1;
	-webkit-transform: scaleY(0.5);
	transform: scaleY(0.5);
	bottom: 0;
	right: 0;
	left: 0;
}

.tui-cell-last::after {
	border-bottom: 0 !important;
}

.tui-header-box {
	display: flex;
	align-items: center;
	justify-content: space-between;
	font-size: 28rpx;
}

.tui-userinfo-box {
	display: flex;
	align-items: center;
}

.tui-avatar {
	width: 64rpx;
	height: 64rpx;
	border-radius: 32rpx;
	display: block;
	flex-shrink: 0;
}

.tui-nickname-box {
	display: flex;
	flex-direction: column;
	justify-content: space-between;
	padding-left: 12rpx;
	padding-top: 4rpx;
	height: 60rpx;
}

.tui-cmt-nickname {
	color: #5677fc;
	line-height: 28rpx;
}

.tui-cmt-time {
	font-size: 24rpx;
	line-height: 24rpx;
	color: #9a9a9a;
	transform: scale(0.8);
	transform-origin: 0 100%;
}

.tui-fabulous {
	color: #9a9a9a;
}

.tui-fabulous text {
	padding-right: 4rpx;
	font-size: 24rpx;
}

.tui-cmt-content {
	font-size: 32rpx;
	color: #333;
	text-align: justify;
	padding-top: 16rpx;
	word-break: break-all;
	word-wrap: break-word;
}

.tui-reply-box {
	border-radius: 8rpx;
	overflow: hidden;
	margin-top: 16rpx;
}

.tui-cell-class {
	flex-direction: column;
	justify-content: flex-start !important;
	padding: 20rpx !important;
	text-align: justify;
	word-break: break-all;
	word-wrap: break-word;
}

.tui-flex-1 {
	flex: 1;
	width: 100%;
}

.tui-reply-nickname {
	font-size: 24rpx;
	color: #7a7a7a;
	padding-bottom: 8rpx;
}

.tui-operation {
	width: 100%;
	padding: 0 30rpx;
	box-sizing: border-box;
	overflow: hidden;
	background: rgba(255, 255, 255, 0.95);
	position: fixed;
	left: 0;
	bottom: 0;
	z-index: 99999;
}

.tui-operation-inner {
	height: 100rpx;
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding-bottom: env(safe-area-inset-bottom);
}

.tui-safearea-bottom {
	width: 100%;
	height: env(safe-area-inset-bottom);
}

.tui-operation::before {
	content: '';
	position: absolute;
	top: 0;
	right: 0;
	left: 0;
	border-top: 1rpx solid #eaeef1;
	-webkit-transform: scaleY(0.5);
	transform: scaleY(0.5);
}

.tui-btn-comment {
	height: 64rpx;
	width: 100%;
	background: #ededed;
	color: #999;
	border-radius: 8rpx;
	font-size: 28rpx;
	display: flex;
	align-items: center;
	padding-left: 20rpx;
	box-sizing: border-box;
	padding-top: 0;
}

.tui-primary {
	color: #5677fc;
}
</style>
